let to_build = packages.iter().find(|p| p.package_id() == pkgid).unwrap();
let targets = try!(generate_targets(to_build, mode, filter, release));
+ let target_with_args = match target_rustc_args {
+ &Some(args) => {
+ if targets.len() > 1 {
+ return Err(human("extra arguments to `rustc` can only be \
+ invoked for one target"))
+ }
+ let (target, profile) = targets[0];
+ let mut profile = profile.clone();
+ profile.rustc_args = Some(args.to_vec());
+ Some((target, profile))
+ },
+ &None => None,
+ };
+
+ let targets = target_with_args.as_ref().map(|&(t, ref p)| vec!((t, p)))
+ .unwrap_or(targets);
+
let ret = {
let _p = profile::start("compiling");
let mut build_config = try!(scrape_build_config(config, jobs, target));
build_config.exec_engine = exec_engine.clone();
build_config.release = release;
- build_config.target_rustc_args = target_rustc_args.map(|a| a.to_vec());
if let CompileMode::Doc { deps } = mode {
build_config.doc_all = deps;
}
pub exec_engine: Option<Arc<Box<ExecEngine>>>,
pub release: bool,
pub doc_all: bool,
- pub target_rustc_args: Option<Vec<String>>,
}
#[derive(Clone, Default)]
opt_level, lto, codegen_units, ref rustc_args, debuginfo, debug_assertions,
rpath, test, doc: _doc,
} = *profile;
- let _ = rustc_args;
// Move to cwd so the root_path() passed below is actually correct
cmd.cwd(cx.config.cwd());
cmd.arg("-g");
}
- if let Some(ref args) = cx.build_config.target_rustc_args {
+ if let &Some(ref args) = rustc_args {
cmd.args(args);
}
.with_stdout(verbose_output_for_target_with_args(false, &p,
"-Z unstable-options")));
});
+
+test!(fails_when_trying_to_build_main_and_lib_with_args {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+
+ name = "foo"
+ version = "0.0.1"
+ authors = ["wycats@example.com"]
+ "#)
+ .file("src/main.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/lib.rs", r#" "#);
+
+
+ assert_that(p.cargo_process("rustc").arg("-v")
+ .arg("--").arg("-Z").arg("unstable-options"),
+ execs()
+ .with_status(101)
+ .with_stderr("extra arguments to `rustc` can only be invoked for one target"));
+});